var proContact = null;
var proPhone = null;
var saveBtn = null;
var backBtn = null;

$(function(){
	proContact = $("#proContact");
	proPhone = $("#proPhone");
	saveBtn = $("#save");
	backBtn = $("#back");
	
	//鍒濆鍖栫殑鏃跺�锛岃鎶婃墍鏈夌殑鎻愮ず淇℃伅鍙樹负锛� 浠ユ彁绀哄繀濉」锛屾洿鐏垫椿锛屼笉瑕佸啓鍦ㄩ〉闈笂
	proContact.next().html("*");
	proPhone.next().html("*");
	
	/*
	 * 楠岃瘉
	 * 澶辩劍\鑾风劍
	 * jquery鐨勬柟娉曚紶閫�
	 */
	proContact.on("focus",function(){
		validateTip(proContact.next(),{"color":"#666666"},"* 璇疯緭鍏ヨ仈绯讳汉",false);
	}).on("blur",function(){
		if(proContact.val() != null && proContact.val() != ""){
			validateTip(proContact.next(),{"color":"green"},imgYes,true);
		}else{
			validateTip(proContact.next(),{"color":"red"},imgNo+" 鑱旂郴浜轰笉鑳戒负绌猴紝璇烽噸鏂拌緭鍏",false);
		}
		
	});
	
	proPhone.on("focus",function(){
		validateTip(proPhone.next(),{"color":"#666666"},"* 璇疯緭鍏ユ墜鏈哄彿",false);
	}).on("blur",function(){
		var patrn=/^(13[0-9]|15[0-9]|18[0-9])\d{8}$/;
		if(proPhone.val().match(patrn)){
			validateTip(proPhone.next(),{"color":"green"},imgYes,true);
		}else{
			validateTip(proPhone.next(),{"color":"red"},imgNo + " 鎮ㄨ緭鍏ョ殑鎵嬫満鍙锋牸寮忎笉姝ｇ‘",false);
		}
	});
	
	saveBtn.on("click",function(){
		proContact.blur();
		proPhone.blur();
		if(proContact.attr("validateStatus") == "true" && 
				proPhone.attr("validateStatus") == "true"){
			if(confirm("vv")){
				$.ajax({
					type:"POTS",
					url:path+"/provider/providermodifysave.json",//�����url
					data:{method:"modifyproviderSave"},//�������
					dataType:"JSON",
					success:function(data){
						if(data != null){
							
						}
					},
					error:function(data){//������ʱ��404��500 �ȷ�200�Ĵ���״̬��
						validateTip(userRole.next(),{"color":"red"},imgNo+" ��ȡ�û���ɫ�б�error",false);
					}
				});
				
			}
		}
	});
	
	backBtn.on("click",function(){
		//alert("modify: "+referer);
		if(referer != undefined 
			&& null != referer 
			&& "" != referer
			&& "null" != referer
			&& referer.length > 4){
		 window.location.href = referer;
		}else{
			history.back(-1);
		}
	});
});